import javax.swing.tree.TreeNode;
import java.util.ArrayList;
import java.util.List;

public class Solution {
    public class TreeNode{
        int val = 0;
        TreeNode left = null;
        TreeNode right = null;
        public TreeNode(int val){
            this.val = val;
        }
    }
    public int[] inorderTraversal (TreeNode root) {
        List<Integer> list = new ArrayList<>();
        inorder(list,root);
        int[] res = new int[list.size()];
        for(int i = 0; i < list.size(); i++){
            res[i] = list.get(i);
        }
        return res;
    }
    public void inorder(List<Integer> list,TreeNode root){
        if(root == null){
            return;
        }
      inorder(list,root.left);
      list.add(root.val);
      inorder(list,root.right);
    }
}
